<!--  -->
<template>
  <div>
    hot
    <vtab :active="2"></vtab>
    <button @click="hanle()">sss</button>
    <van-button @click="hanle()" class="sub" size="small">订阅</van-button>
    <van-dialog id="van-dialog" />
  </div>
</template>

<script>
import Vatabbar from '../commponents/tabbar/vatabbar'
// import Dialog from '@vant/weapp/dist/dialog/dialog'
import { checkAuth, confirmAuth } from '@/utils/checkAuth'
export default {
  name: '',
  components: {
    'vtab': Vatabbar
  },
  data () {
    return {
      islogin: false
    }
  },
  computed: {},
  async onShow () {
    this.islogin = await checkAuth()
    console.log('this.islogin', this.islogin)
  },
  mounted () { },

  methods: {
    hanle () {
      if (!this.islogin) {
        confirmAuth()
      } else {
        this.subscribe()
      }
      // Dialog.confirm({
      //   title: '标题',
      //   message: '弹窗内容'
      // })
      //   .then(() => {
      //     // on confirm
      //     console.log('login')
      //     wx.navigateTo({ url: '/pages/login/main' })
      //   })
      //   .catch(() => {
      //     // on cancel
      //     console.log('cancle')
      //   })
    },
    subscribe () {
      var arr = [
        'J9H_DEvG6dZp29jzqZ3qv6xOAF3rPWhnk5KVCmFXH9Q'
      ]
      const tmplIds = getApp().globalDta.tmplIds.filter((item) => arr.indexOf(item) !== -1)
      wx.requestSubscribeMessage({
        tmplIds: tmplIds,
        success (res) {
          console.log(res)
        }
      })
    },
  }
}
</script>
<style scoped  >
</style>
